﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;

namespace VortexFlyff
{
    class Connect
    {
        public int loginPort = 23000,
                    charPort = 28000,
                    worldPort = 5400;

        public string host = "127.0.0.1"; // local host
       

        public void charConnect()
        {
           

            
        }

        //public void LoginConnect()
        //{
        //    IPAddress[] IPs = Dns.GetHostAddresses(host);

        //    Socket loginServ = new Socket(AddressFamily.InterNetwork,
        //        SocketType.Stream,
        //        ProtocolType.Tcp);

        //    Console.WriteLine("Establishing Connection to Port Number {0}",
        //        loginPort.ToString());

        //    try
        //    {
        //        loginServ.Connect(IPs[0], loginPort);
        //        Console.WriteLine("Connection established");
        //    }
        //    catch (Exception ex)    // if you can't establish a connection with the port
        //    {
        //        Console.WriteLine("Can't connect");
        //        Console.ReadLine();


        //    }
        //}
       public bool LoginConnect(string host, int port)
        {
            Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            try
            {
                socket.Connect(host, loginPort);
                socket.Close();
                return true;
            }
            catch
            {
                Console.WriteLine("Couldn't connect");
                Console.ReadLine();
                return false;
            }
        }
 

        public void CharConnect()
        {
            Socket charServ = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            IPAddress[] IPs = null;
            Console.WriteLine("Establising Connection to port {0}", charPort.ToString());
            charServ.Connect(IPs, charPort);


        }

        public void WorldConnect()
        {
            Socket worldServ = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            IPAddress[] IPs = null;
            Console.WriteLine("Establishing Connection to Port {0}", worldServ.ToString());
            worldServ.Connect(IPs, charPort);


        }



    }
}
